﻿/*  Eleven Business Suite : Un ERP básico para pequeños empresarios.
 *  Copyright (C) 2011  Francis Bolaños Arias
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>;.
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ElevenGUI
{
    public partial class UCMenuCRM : UserControl
    {
        private FrmAcercaDe acerca = new FrmAcercaDe();
        private bool acercaDeAbierto = false;
        private FrmClientes cliente = new FrmClientes();
        private bool clienteAbierto = false;
        private FrmConsultas consulta = new FrmConsultas();
        private bool llamadaAbierto = false;

        public UCMenuCRM()
        {
            InitializeComponent();
        }

        private void cliente_Closed(object sender, FormClosedEventArgs e)
        {
            clienteAbierto = false;
        }

        private void acercaDe_Closed(object sender, FormClosedEventArgs e)
        {
            acercaDeAbierto = false;
        }

        private void llamada_Closed(object sender, FormClosedEventArgs e)
        {
            llamadaAbierto = false;
        }

        private void btnClientes_Click(object sender, EventArgs e)
        {
            if (!clienteAbierto)
            {
                cliente = new FrmClientes();
                cliente.FormClosed += new FormClosedEventHandler(cliente_Closed);
                cliente.Show(this);
                clienteAbierto = true;
            }
            else
            {
                GLOMensajeAceptar mensaje = new GLOMensajeAceptar("Ya hay una ventana de clientes abierta");
                mensaje.ShowDialog();
                cliente.Focus();
            }
        }

        private void btnAcerca_Click(object sender, EventArgs e)
        {
            if (!acercaDeAbierto)
            {
                acerca = new FrmAcercaDe();
                acerca.FormClosed += new FormClosedEventHandler(acercaDe_Closed);
                acerca.Show(this);
                acercaDeAbierto = true;
            }
            else
            {
                acerca.Focus();
            }
        }

        private void btnSalir_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnLlamadas_Click(object sender, EventArgs e)
        {
            if (!llamadaAbierto)
            {
                consulta = new FrmConsultas();
                consulta.FormClosed += new FormClosedEventHandler(llamada_Closed);
                consulta.Show(this);
                llamadaAbierto = true;
            }
            else
            {
                GLOMensajeAceptar mensaje = new GLOMensajeAceptar("Ya hay una ventana de llamadas abierta");
                mensaje.ShowDialog();
                consulta.Focus();
            }
        }

        private void btnConfig_Click(object sender, EventArgs e)
        {

        }
    }
}
